package com.ambow.store.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ambow.store.entity.DictDistrict;
import com.ambow.store.service.DictDistrictService;
import com.ambow.store.mapper.DictDistrictMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author MyComputer
* @description 针对表【t_dict_district】的数据库操作Service实现
* @createDate 2022-11-09 09:59:18
*/
@Service
public class DictDistrictServiceImpl extends ServiceImpl<DictDistrictMapper, DictDistrict> implements DictDistrictService{
    @Autowired
    private DictDistrictMapper districtMapper;

    @Override
    public List<DictDistrict> getByPrint(DictDistrict dictDistrict) {
        LambdaQueryWrapper<DictDistrict> dictDistrictLambdaQueryWrapper = new LambdaQueryWrapper<>();
        dictDistrictLambdaQueryWrapper.eq(DictDistrict::getParent,dictDistrict.getParent());
        List<DictDistrict> dictDistricts = districtMapper.selectList(dictDistrictLambdaQueryWrapper);
        return dictDistricts;
    }

    @Override
    public DictDistrict getNameByCode(String code) {
        LambdaQueryWrapper<DictDistrict> dictDistrictLambdaQueryWrapper = new LambdaQueryWrapper<>();
        dictDistrictLambdaQueryWrapper.eq(DictDistrict::getCode,code);
        DictDistrict data = this.getOne(dictDistrictLambdaQueryWrapper);
        return data;
    }
}




